import React from 'react';
import styles from './Login.less';
import { Link } from 'umi';
import { Button, Input, Form, Checkbox, message } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import { userLogin } from '../../api/user';
export default function Login(props) {
  let { isShow, handleLoginClick } = props;

  if (!isShow) return null;
  function onFinish(val) {
    console.log(val);
    userLogin(val).then((lcz) => {
      console.log(lcz);
    });
  }
  return (
    <div className={`${styles['login']}`}>
      <div className={`${styles['warp']}`}>
        <div className={`${styles['head']}`}>
          <span>登录</span>
          <i
            className={`${styles['close']} icon-guanbi iconfont click`}
            onClick={handleLoginClick}
          ></i>
        </div>
        <div className={`${styles['from-box']}`}>
          <Form
            name="normal_login"
            className={styles['login-form']}
            onFinish={onFinish}
            initialValues={{
              remember: true,
              phone: '17711280780',
              password: 'lichunzhuo',
            }}
          >
            <Form.Item
              name="phone"
              rules={[
                {
                  required: true,
                  message: '请输入用户名!',
                },
              ]}
            >
              <Input
                prefix={<UserOutlined className="site-form-item-icon" />}
                placeholder="用户名"
              />
            </Form.Item>
            <Form.Item
              name="password"
              rules={[
                {
                  required: true,
                  message: '请输入密码!',
                },
              ]}
            >
              <Input
                prefix={<LockOutlined className="site-form-item-icon" />}
                type="password"
                placeholder="密码"
              />
            </Form.Item>

            <Form.Item>
              <Button
                type="primary"
                htmlType="submit"
                className="login-form-button"
              >
                登录
              </Button>
            </Form.Item>
          </Form>
        </div>
      </div>
    </div>
  );
}
